/*-
 * Copyright (c) 2009-2010 David Forsythe.
 * See LICENSE file for license details.
 */

#ifndef __LIBPKG_DATABASE_H__
#define __LIBPKG_DATABASE_H__

#include <sys/types.h>

#include "pkg.h"

/* XXX: Init's for database types. */
void pkg_database_directorydb_init(struct pkg_database *);

struct pkg_database *pkg_database_create(void);

void pkg_database_release(struct pkg_database *);

/* Get the next package in a database. */
int pkg_database_get_next_pkg(struct pkg_database *, struct pkg *, u_int);

/* Get the current package (again). */
int pkg_database_get_pkg(struct pkg_database *, struct pkg *, u_int);

/* Reset the cursor in a database. */
void pkg_database_rewind(struct pkg_database *);

/* Open a database for interaction. */
int pkg_database_open(struct pkg_database *, const char *, u_int);

/* Close a database. */
int pkg_database_close(struct pkg_database *);

/* Add a package to a database. */
int pkg_database_add_pkg(struct pkg_database *, struct pkg *, u_int);

/* Remove a package (by key) from a database. */
int pkg_database_remove_pkg(struct pkg_database *, const char *);

#endif
